package com.ffcs.trino.exception;

import com.ffcs.trino.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author zhangzhengxing
 */
@ControllerAdvice
@RestController
@Slf4j
public class GlobalException {

  /**
   * 其他异常抛出
   *
   * @param exception
   * @return
   */
  @ExceptionHandler(Exception.class)
  public R<String> getController(Exception exception) {
    return R.error("请求异常：" + exception.getMessage());
  }
}
